<%@ page language="java" import="java.util.*,com.web.util.*" pageEncoding="utf-8"%>

<%@taglib  prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'QueryEmpByPage.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    

	<link rel="stylesheet" href="css/css.css"  type="text/css"></link>


	<script type="text/javascript">
	
		function gotoPage(){
			var pageCode = document.getElementById("txtPageCode").value;
			location="/WebDemo2/servlet/EmpServlet?method=getEmpsByPage&pageCode="+pageCode;
		}
	</script>

  
  
  </head>
  
  <body>
		<a href="/WebDemo2/jsp/index.jsp" >返回</a>
	
	 	<!-- 如果 查询为空 则跳转到，显示所有界面 -->
	 	<c:if test="${empty requestScope.pageBean }">
			<script>location="/WebDemo2/servlet/EmpServlet?method=getEmps";</script>
		</c:if>
	
	 	<!-- 此段div代码构造结果类似于  ~~     第 [1]  [2]  [3]  4   [5]  [6]  页-->
	 	<div align="center"  class="viciao">
      		<span>总共：${requestScope.pageBean.totalRows } 条记录</span>
      		<span>请选择： 第 
      			<c:forEach var="i"  begin="1" end="${requestScope.pageBean.totalPages }">
      				<c:if test="${requestScope.pageBean.currentPage ne i }"> 
      					<a href="/WebDemo2/servlet/EmpServlet?method=getEmpsByPage&pageCode=${i }">${i }</a>
 					</c:if> 	
     				<c:if test="${requestScope.pageBean.currentPage eq i }">
      					<span class="current">${i}</span>
      				</c:if>      
      			</c:forEach>
             页</span>
	 	</div>
	 	
	 	<table width="60%" border="1" align="center">
   
		<tr bgcolor="#CCCCCC">
			<td>序号</td>
			<td>姓名</td>
			<td>性别</td>
			<td>学历</td>
			<td>工作经历</td>
			<td>操作</td>
		</tr>
				
		<c:forEach  var="emp"   items="${requestScope.pageBean.data }"  varStatus="index" >
			

			<tr bgcolor="CFEEFA">
				<td>${index.count }</td>
				<td>${emp.name }</td>
				<td>
					<c:if test="${emp.sex eq 0 }">
						<c:out value="男"></c:out>
					</c:if>
					<c:if test="${emp.sex eq 1 }">
						<c:out value="女"></c:out>
					</c:if>
				</td>
				<td>${emp.degree }</td>
				<td>${emp.work }</td>
				<td>
					<a href="servlet/EmpServlet?method=getEmp&id=${emp.id }">修改</a>
					<a href="servlet/EmpServlet?method=removeEmp&id=${emp.id }">删除</a>
				</td>

			</tr>
		</c:forEach>

	</table>
	
	<div align="center" class="viciao">
		<!-- 此段代码构造结果类似于  ~~     第 [1]  [2]  [3]  4   [5]  [6]  页-->
		<span>
      		 请选择： 第      
     		 <c:forEach var="i" begin="1" end="${requestScope.pageBean.totalPages }">
      			<c:if test="${requestScope.pageBean.currentPage ne i }">
      				<a href="/WebDemo2/servlet/EmpServlet?method=getEmpsByPage&pageCode=${i }">${i }</a>
      			</c:if> 
      			<c:if test="${requestScope.pageBean.currentPage eq i }">
      				<span class="current">${i}</span>
      			</c:if>      	
     		 </c:forEach>
              页  
          </span>  
          <span>
              跳转至
              <label>
              	<select name="txtPageCode" id="txtPageCode" onchange="javascript:gotoPage(this);">
                  <c:forEach var="i" begin="1" end="${requestScope.pageBean.totalPages }">
                  	<c:if test="${requestScope.pageBean.currentPage ne i }">
                  		<option value="${i }">${i }</option>
                  	</c:if>
                  	<c:if test="${requestScope.pageBean.currentPage eq i }">
                  		<option value="${i }" selected="selected">${i }</option>
                  	</c:if>
                  </c:forEach>
                </select>
                页
                </label>
            </span>    
            
      		<span>当前： 第${requestScope.pageBean.currentPage } / ${requestScope.pageBean.totalPages }页</span>

		</div>
	 	
   	
  </body>
</html>
